package com.cms.web.servlet;

import com.cms.pojo.Admin;
import com.cms.pojo.Student;
import com.cms.service.AdminService;
import com.cms.service.CourseService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet("/courseStudentServlet")
public class CourseStudentServlet extends HttpServlet {
    private AdminService courseService = new AdminService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 课程id
        int id = Integer.parseInt(request.getParameter("id"));

        List<Student> students = courseService.courseStudent(id);

        request.setAttribute("students", students);
        request.setAttribute("course_id", id);

        request.getRequestDispatcher("courseStudent.jsp").forward(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
